
/**
  ******************************************************************************
  * Copyright 2021 The Microbee Authors. All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * 
  * http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
  * @file       sensor_gps_param.c
  * @author     baiyang
  * @date       2022-2-20
  ******************************************************************************
  */

/*----------------------------------include-----------------------------------*/
#include "sensor_gps.h"
#include <parameter/param.h>
/*-----------------------------------macro------------------------------------*/

/*----------------------------------typedef-----------------------------------*/

/*---------------------------------prototype----------------------------------*/

/*----------------------------------variable----------------------------------*/
static param_t var_info[] = {
    PARAM_DEFINE_INT8(GPS_TYPE, 1),
    PARAM_DEFINE_INT8(GPS_TYPE2, 0),
    PARAM_DEFINE_INT8(GPS_NAVFILTER, 8),
    PARAM_DEFINE_INT8(GPS_AUTO_SWITCH, 1),
    PARAM_DEFINE_INT8(GPS_MIN_DGPS, 100),
    PARAM_DEFINE_INT8(GPS_SBAS_MODE, 2),
    PARAM_DEFINE_INT8(GPS_MIN_ELEV, -100),
    PARAM_DEFINE_INT8(GPS_INJECT_TO, 127),
    PARAM_DEFINE_INT16(GPS_SBP_LOGMASK, -256),
    PARAM_DEFINE_INT8(GPS_RAW_DATA, 0),
    PARAM_DEFINE_INT8(GPS_GNSS_MODE, 0),
    PARAM_DEFINE_INT8(GPS_SAVE_CFG, 2),
    PARAM_DEFINE_INT8(GPS_GNSS_MODE2, 0),
    PARAM_DEFINE_INT8(GPS_AUTO_CONFIG, 1),
    PARAM_DEFINE_INT16(GPS_RATE_MS, 200),
    PARAM_DEFINE_INT16(GPS_RATE_MS2, 200),
    PARAM_DEFINE_FLOAT(GPS_POS1_X, 0.0f),
    PARAM_DEFINE_FLOAT(GPS_POS1_Y, 0.0f),
    PARAM_DEFINE_FLOAT(GPS_POS1_Z, 0.0f),
    PARAM_DEFINE_FLOAT(GPS_POS2_X, 0.0f),
    PARAM_DEFINE_FLOAT(GPS_POS2_Y, 0.0f),
    PARAM_DEFINE_FLOAT(GPS_POS2_Z, 0.0f),
    PARAM_DEFINE_INT16(GPS_DELAY_MS, 0),
    PARAM_DEFINE_INT16(GPS_DELAY_MS2, 0),
    PARAM_DEFINE_INT8(GPS_BLEND_MASK, 5),
    PARAM_DEFINE_FLOAT(GPS_BLEND_TC, 10.0f),
    PARAM_DEFINE_INT16(GPS_DRV_OPTIONS, 0),
    PARAM_DEFINE_INT8(GPS_COM_PORT, 1),
    PARAM_DEFINE_INT8(GPS_COM_PORT2, 1),
    PARAM_DEFINE_INT8(GPS_PRIMARY, 0),
#if GPS_MOVING_BASELINE
    // @Param: TYPE
    // @DisplayName: Moving base type
    // @Description: Controls the type of moving base used if using moving base.
    // @Values: 0:Relative to alternate GPS instance,1:RelativeToCustomBase
    // @User: Advanced
    // @RebootRequired: True
    PARAM_DEFINE_INT8(GPS_MB1_TYPE, 0),

    // @Param: OFS_X
    // @DisplayName: Base antenna X position offset
    // @Description: X position of the base (primary) GPS antenna in body frame from the position of the 2nd antenna. Positive X is forward of the 2nd antenna. Use antenna phase centroid location if provided by the manufacturer.
    // @Units: m
    // @Range: -5 5
    // @Increment: 0.01
    // @User: Advanced
    PARAM_DEFINE_FLOAT(GPS_MB1_OFS_X, 0.0f),

    // @Param: OFS_Y
    // @DisplayName: Base antenna Y position offset    
    // @Description: Y position of the base (primary) GPS antenna in body frame from the position of the 2nd antenna. Positive Y is to the right of the 2nd antenna. Use antenna phase centroid location if provided by the manufacturer.
    // @Units: m
    // @Range: -5 5
    // @Increment: 0.01
    // @User: Advanced
    PARAM_DEFINE_FLOAT(GPS_MB1_OFS_Y, 0.0f),

    // @Param: OFS_Z
    // @DisplayName: Base antenna Z position offset
    // @Description: Z position of the base (primary) GPS antenna in body frame from the position of the 2nd antenna. Positive Z is down from the 2nd antenna. Use antenna phase centroid location if provided by the manufacturer.
    // @Units: m
    // @Range: -5 5
    // @Increment: 0.01
    // @User: Advanced
    PARAM_DEFINE_FLOAT(GPS_MB1_OFS_Z, 0.0f),
#if GPS_MAX_RECEIVERS > 1
    // @Param: TYPE
    // @DisplayName: Moving base type
    // @Description: Controls the type of moving base used if using moving base.
    // @Values: 0:Relative to alternate GPS instance,1:RelativeToCustomBase
    // @User: Advanced
    // @RebootRequired: True
    PARAM_DEFINE_INT8(GPS_MB2_TYPE, 0),

    // @Param: OFS_X
    // @DisplayName: Base antenna X position offset
    // @Description: X position of the base (primary) GPS antenna in body frame from the position of the 2nd antenna. Positive X is forward of the 2nd antenna. Use antenna phase centroid location if provided by the manufacturer.
    // @Units: m
    // @Range: -5 5
    // @Increment: 0.01
    // @User: Advanced
    PARAM_DEFINE_FLOAT(GPS_MB2_OFS_X, 0.0f),

    // @Param: OFS_Y
    // @DisplayName: Base antenna Y position offset    
    // @Description: Y position of the base (primary) GPS antenna in body frame from the position of the 2nd antenna. Positive Y is to the right of the 2nd antenna. Use antenna phase centroid location if provided by the manufacturer.
    // @Units: m
    // @Range: -5 5
    // @Increment: 0.01
    // @User: Advanced
    PARAM_DEFINE_FLOAT(GPS_MB2_OFS_Y, 0.0f),

    // @Param: OFS_Z
    // @DisplayName: Base antenna Z position offset
    // @Description: Z position of the base (primary) GPS antenna in body frame from the position of the 2nd antenna. Positive Z is down from the 2nd antenna. Use antenna phase centroid location if provided by the manufacturer.
    // @Units: m
    // @Range: -5 5
    // @Increment: 0.01
    // @User: Advanced
    PARAM_DEFINE_FLOAT(GPS_MB2_OFS_Z, 0.0f),
#endif // GPS_MAX_RECEIVERS > 1
#endif // GPS_MOVING_BASELINE
};
PARAM_GROUP_DEFINE(GPS, var_info);
/*-------------------------------------os-------------------------------------*/

/*----------------------------------function----------------------------------*/
/**
  * @brief       
  * @param[in]     
  * @param[out]  
  * @retval      
  * @note        
  */
void sensor_gps_assign_param()
{
    param_link_variable(PARAM_ID(GPS, GPS_TYPE), &gps._type[0]);
    param_link_variable(PARAM_ID(GPS, GPS_TYPE2), &gps._type[1]);
    param_link_variable(PARAM_ID(GPS, GPS_NAVFILTER), &gps._navfilter);
    param_link_variable(PARAM_ID(GPS, GPS_AUTO_SWITCH), &gps._auto_switch);
    param_link_variable(PARAM_ID(GPS, GPS_MIN_DGPS), &gps._min_dgps);
    param_link_variable(PARAM_ID(GPS, GPS_SBAS_MODE), &gps._sbas_mode);
    param_link_variable(PARAM_ID(GPS, GPS_MIN_ELEV), &gps._min_elevation);
    param_link_variable(PARAM_ID(GPS, GPS_INJECT_TO), &gps._inject_to);
    param_link_variable(PARAM_ID(GPS, GPS_SBP_LOGMASK), &gps._sbp_logmask);
    param_link_variable(PARAM_ID(GPS, GPS_RAW_DATA), &gps._raw_data);
    param_link_variable(PARAM_ID(GPS, GPS_GNSS_MODE), &gps._gnss_mode[0]);
    param_link_variable(PARAM_ID(GPS, GPS_SAVE_CFG), &gps._save_config);
    param_link_variable(PARAM_ID(GPS, GPS_GNSS_MODE2), &gps._gnss_mode[1]);
    param_link_variable(PARAM_ID(GPS, GPS_AUTO_CONFIG), &gps._auto_config);
    param_link_variable(PARAM_ID(GPS, GPS_RATE_MS), &gps._rate_ms[0]);
    param_link_variable(PARAM_ID(GPS, GPS_RATE_MS2), &gps._rate_ms[1]);
    param_link_variable(PARAM_ID(GPS, GPS_POS1_X), &gps._antenna_offset[0].x);
    param_link_variable(PARAM_ID(GPS, GPS_POS1_Y), &gps._antenna_offset[0].y);
    param_link_variable(PARAM_ID(GPS, GPS_POS1_Z), &gps._antenna_offset[0].z);
    param_link_variable(PARAM_ID(GPS, GPS_POS2_X), &gps._antenna_offset[1].x);
    param_link_variable(PARAM_ID(GPS, GPS_POS2_Y), &gps._antenna_offset[1].y);
    param_link_variable(PARAM_ID(GPS, GPS_POS2_Z), &gps._antenna_offset[1].z);
    param_link_variable(PARAM_ID(GPS, GPS_DELAY_MS), &gps._delay_ms[0]);
    param_link_variable(PARAM_ID(GPS, GPS_DELAY_MS2), &gps._delay_ms[1]);
    param_link_variable(PARAM_ID(GPS, GPS_BLEND_MASK), &gps._blend_mask);
    param_link_variable(PARAM_ID(GPS, GPS_BLEND_TC), &gps._blend_tc);
    param_link_variable(PARAM_ID(GPS, GPS_DRV_OPTIONS), &gps._driver_options);
    param_link_variable(PARAM_ID(GPS, GPS_COM_PORT), &gps._com_port[0]);
    param_link_variable(PARAM_ID(GPS, GPS_COM_PORT2), &gps._com_port[1]);
    param_link_variable(PARAM_ID(GPS, GPS_PRIMARY), &gps._primary);

#if GPS_MOVING_BASELINE
    param_link_variable(PARAM_ID(GPS, GPS_MB1_TYPE), &gps.mb_params[0].type);
    param_link_variable(PARAM_ID(GPS, GPS_MB1_OFS_X), &gps.mb_params[0].base_offset.x);
    param_link_variable(PARAM_ID(GPS, GPS_MB1_OFS_Y), &gps.mb_params[0].base_offset.y);
    param_link_variable(PARAM_ID(GPS, GPS_MB1_OFS_Z), &gps.mb_params[0].base_offset.z);
#if GPS_MAX_RECEIVERS > 1
    param_link_variable(PARAM_ID(GPS, GPS_MB2_TYPE), &gps.mb_params[1].type);
    param_link_variable(PARAM_ID(GPS, GPS_MB2_OFS_X), &gps.mb_params[1].base_offset.x);
    param_link_variable(PARAM_ID(GPS, GPS_MB2_OFS_Y), &gps.mb_params[1].base_offset.y);
    param_link_variable(PARAM_ID(GPS, GPS_MB2_OFS_Z), &gps.mb_params[1].base_offset.z);
#endif // GPS_MAX_RECEIVERS > 1
#endif // GPS_MOVING_BASELINE
}

/*------------------------------------test------------------------------------*/


